package com.anywhere.freightman.system.dao;

import com.anywhere.freightman.common.BaseMapper;
import com.anywhere.freightman.system.model.Resource;
import com.anywhere.freightman.system.model.Role;
import com.anywhere.freightman.system.model.UserModel;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Set;

@Mapper
@Repository
public interface RoleDao extends BaseMapper<Role> {

    List<Role> getListByUserId(long userId);

    Set<Resource> getResource(long roleId);

    Set<Resource> getResourceByUserId(long userId);

    List<Role> getListByTenantId(long tenantId);

    void deleteRole(Long userId);

    void insertRole(@Param("userId") Long userId, @Param("roleIds") List<Long> roleIds);

    void insertRoleRes(@Param("roleId") Long roleId, @Param("resIds") List<Long> resIds);

    void deleteRoleRes(@Param("roleId") Long roleId);

    List<UserModel> getUserListByRoleId(long roleId);

    Role getByCode(@Param("code") String code);
}
